package logic

import (
	"context"
	"shuqi-novel/model"

	"shuqi-novel/shuqirpc/internal/svc"
	"shuqi-novel/shuqirpc/shuqirpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpNovelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpNovelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpNovelLogic {
	return &UpNovelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpNovelLogic) UpNovel(in *shuqirpc.UpNovelRequest) (*shuqirpc.UpNovelResponse, error) {
	// todo: add your logic here and delete this line
	var novel model.Novel
	novel = model.Novel{
		Title:  in.Title,
		Image:  in.Image,
		UserId: int(in.UserId),
	}
	model.DB.Create(&novel)
	return &shuqirpc.UpNovelResponse{
		NovelId: int64(novel.ID),
	}, nil
}
